#include<bits/stdc++.h>
using namespace std;
#define int long long


bool check(vector<int> a, int begin, int n, int k) {
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i + begin];
	}
	for (int i = 0; i < n; i++) {
		if ((sum - a[i + begin]) % k == a[i + begin])
			return true;
	}
	return false;
}


int solution_n3(vector<int> a, int n, int k) {
	int ans = 0;
	for (int siz = 2; siz <= n; siz++) {
		for (int i = 0; i < n; i++) {
			if (i + siz <= n && check(a, i, siz, k))
				ans++;
		}
	}
	return ans;
}



int solution_n2k(vector<int> a, int n, int k) {
	int ans = 0;

	vector<int> nums[15];
	vector<int> preSum(n + 1);

	for (int i = 1; i <= n; i++) {
		preSum[i] = preSum[i - 1] + a[i - 1];
		nums[a[i - 1]].push_back(i - 1);
	}

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int x = 0; x < k; x++) {
				auto idx = lower_bound(nums[x].begin(), nums[x].end(), i);

				if (idx == nums[x].end())
					continue;

				if (*idx <= j && (preSum[j + 1] - preSum[i] - a[*idx]) % k == x) {
					ans++;
					break;
				}
			}
		}
	}
	return ans;
}


signed main() {
//	system("start https://www.lanqiao.cn/problems/3929/learning/");

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int &i : a)
		cin >> i;


	cout << solution_n2k(a, n, k);

	return 0;
}
